<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Origami::Dictionary</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Origami::Dictionary</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/origami/obfuscation_rb.html">
                origami/obfuscation.rb
                </a>
        <br />
                <a href="../../files/origami/docmdp_rb.html">
                origami/docmdp.rb
                </a>
        <br />
                <a href="../../files/origami/dictionary_rb.html">
                origami/dictionary.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Class representing a <a href="Dictionary.html">Dictionary</a> <a
href="Object.html">Object</a>. Dictionaries are containers associating a <a
href="Name.html">Name</a> to an embedded <a href="Object.html">Object</a>.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000393">[]</a>&nbsp;&nbsp;
      <a href="#M000392">[]=</a>&nbsp;&nbsp;
      <a href="#M000395">delete</a>&nbsp;&nbsp;
      <a href="#M000394">has_key?</a>&nbsp;&nbsp;
      <a href="#M000390">map!</a>&nbsp;&nbsp;
      <a href="#M000391">merge</a>&nbsp;&nbsp;
      <a href="#M000389">new</a>&nbsp;&nbsp;
      <a href="#M000396">real_type</a>&nbsp;&nbsp;
      <a href="#M000388">to_docmdp_str</a>&nbsp;&nbsp;
      <a href="#M000387">to_obfuscated_str</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="Object.html">Origami::Object</a></span>
      </div>
    </div>

    <div id="section">



    <div id="aliases-list">
      <h3 class="section-bar">External Aliases</h3>

      <div class="name-list">
                        <table summary="aliases">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">to_hash</td>
          <td>-&gt;</td>
          <td class="context-item-value">to_h</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">each_value</td>
          <td>-&gt;</td>
          <td class="context-item-value">each</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">to_h</td>
          <td>-&gt;</td>
          <td class="context-item-value">value</td>
        </tr>
                        </table>
      </div>
    </div>


    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">strings_cache</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000389" class="method-detail">
        <a name="M000389"></a>

        <div class="method-heading">
          <a href="#M000389" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(hash = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a <a href="Dictionary.html#M000389">new</a> <a
href="Dictionary.html">Dictionary</a>.
</p>
<table>
<tr><td valign="top"><em>hash</em>:</td><td>The hash representing the <a href="Dictionary.html#M000389">new</a> <a
href="Dictionary.html">Dictionary</a>.

</td></tr>
</table>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000389-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000389-source">
<pre>
    <span class="ruby-comment cmt"># File origami/dictionary.rb, line 48</span>
48:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hash</span> = {})
49:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Expected type Hash, received #{hash.class}.&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
50:         <span class="ruby-keyword kw">super</span>()
51:         
52:         <span class="ruby-ivar">@strings_cache</span> = []
53:         <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
54:           <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">val</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_o</span>
55:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span> <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@strings_cache</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">val</span>
56:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Dictionary</span>,<span class="ruby-constant">Array</span> <span class="ruby-keyword kw">then</span> 
57:               <span class="ruby-ivar">@strings_cache</span> <span class="ruby-operator">|=</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">strings_cache</span>
58:               <span class="ruby-identifier">val</span>.<span class="ruby-identifier">strings_cache</span>.<span class="ruby-identifier">clear</span>
59:           <span class="ruby-keyword kw">end</span>
60: 
61:           <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_o</span>] = <span class="ruby-identifier">val</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">nil?</span>
62:         }
63:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000393" class="method-detail">
        <a name="M000393"></a>

        <div class="method-heading">
          <a href="#M000393" class="method-signature">
          <span class="method-name">[]</span><span class="method-args">(key)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000393-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000393-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 143</span>
143:       <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
144:         <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_o</span>)
145:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000392" class="method-detail">
        <a name="M000392"></a>

        <div class="method-heading">
          <a href="#M000392" class="method-signature">
          <span class="method-name">[]=</span><span class="method-args">(key,val)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000392-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000392-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 124</span>
124:       <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span>)
125:         
126:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Name</span>)
127:           <span class="ruby-identifier">fail</span> <span class="ruby-node">&quot;Expecting a Name for a Dictionary entry, found #{key.class} instead.&quot;</span>
128:         <span class="ruby-keyword kw">end</span>
129:         
130:         <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_o</span>
131:         <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span>
132:           <span class="ruby-identifier">val</span> = <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_o</span>
133:           <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span>)
134:         
135:           <span class="ruby-identifier">key</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">val</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-keyword kw">self</span>
136: 
137:           <span class="ruby-identifier">val</span>
138:         <span class="ruby-keyword kw">else</span>
139:           <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
140:         <span class="ruby-keyword kw">end</span>
141:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000395" class="method-detail">
        <a name="M000395"></a>

        <div class="method-heading">
          <a href="#M000395" class="method-signature">
          <span class="method-name">delete</span><span class="method-args">(key)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000395-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000395-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 151</span>
151:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
152:         <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_o</span>)
153:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000394" class="method-detail">
        <a name="M000394"></a>

        <div class="method-heading">
          <a href="#M000394" class="method-signature">
          <span class="method-name">has_key?</span><span class="method-args">(key)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000394-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000394-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 147</span>
147:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>)
148:         <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_o</span>)
149:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000390" class="method-detail">
        <a name="M000390"></a>

        <div class="method-heading">
          <a href="#M000390" class="method-signature">
          <span class="method-name">map!</span><span class="method-args">(&amp;b)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000390-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000390-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 112</span>
112:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map!</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)
113:         
114:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
115:           <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">v</span>)
116:         }
117:         
118:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000391" class="method-detail">
        <a name="M000391"></a>

        <div class="method-heading">
          <a href="#M000391" class="method-signature">
          <span class="method-name">merge</span><span class="method-args">(dict)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000391-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000391-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 120</span>
120:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">dict</span>)
121:         <span class="ruby-constant">Dictionary</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">dict</span>))
122:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000396" class="method-detail">
        <a name="M000396"></a>

        <div class="method-heading">
          <a href="#M000396" class="method-signature">
          <span class="method-name">real_type</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000396-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000396-source">
<pre>
     <span class="ruby-comment cmt"># File origami/dictionary.rb, line 157</span>
157:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">real_type</span> ; <span class="ruby-constant">Dictionary</span> <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000388" class="method-detail">
        <a name="M000388"></a>

        <div class="method-heading">
          <a href="#M000388" class="method-signature">
          <span class="method-name">to_docmdp_str</span><span class="method-args">(*fields)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000388-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000388-source">
<pre>
    <span class="ruby-comment cmt"># File origami/docmdp.rb, line 65</span>
65:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_docmdp_str</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">fields</span>)
66:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fields</span>.<span class="ruby-identifier">empty?</span>
67:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
68:           
69:         }
70:       <span class="ruby-keyword kw">else</span>
71: 
72:       <span class="ruby-keyword kw">end</span>
73:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000387" class="method-detail">
        <a name="M000387"></a>

        <div class="method-heading">
          <a href="#M000387" class="method-signature">
          <span class="method-name">to_obfuscated_str</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000387-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000387-source">
<pre>
     <span class="ruby-comment cmt"># File origami/obfuscation.rb, line 117</span>
117:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_obfuscated_str</span>
118:       <span class="ruby-identifier">content</span> = <span class="ruby-constant">TOKENS</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Obfuscator</span>.<span class="ruby-identifier">junk_spaces</span>
119:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
120:         <span class="ruby-identifier">content</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Obfuscator</span>.<span class="ruby-identifier">junk_spaces</span> <span class="ruby-operator">+</span> 
121:           <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_obfuscated_str</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Obfuscator</span>.<span class="ruby-identifier">junk_spaces</span> <span class="ruby-operator">+</span> 
122:           <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_obfuscated_str</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Obfuscator</span>.<span class="ruby-identifier">junk_spaces</span>
123:       }
124: 
125:       <span class="ruby-identifier">content</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">TOKENS</span>.<span class="ruby-identifier">last</span>
126:       <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">content</span>)
127:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>